An improved insert sort algorithm

نویسندگان

  • Olli Nevalainen
  • Timo Raita
  • Harold Thimbleby
چکیده

Many algorithms involve a search, and they typically require two types of test: one test checks for the element being searched for, and another test is required to check the search remains within the bounds of the data structure being searched. Both of these tests can be combined into one by using a so-called sentinel. In particular, sentinels can be used in insert sort algorithms to make them more efficient, effectively halving the number of tests in a loop. An insert sort suggested by Thimbleby, 1 which has the advantage of neither requiring extra memory nor a special value (such as MAX VALUE) that cannot be sorted, however repeatedly re-computes a sentinel value, an operation which itself incurs a time penalty. Since the sentinel value for insert sort is an extremal element, one can be found and placed in position in linear time, and this need only be done once. Using this idea, this paper gives Java code to sort a given array a into increasing order. Algorithms are presented for both stable and (the more efficient) unstable sorts.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A new trust-region algorithm based on radial basis function interpolation

Optimization using radial basis functions as an interpolation tool in trust-region (ORBIT), is a derivative-free framework based on fully linear models to solve unconstrained local optimization, especially when the function evaluations are computationally expensive. This algorithm stores the interpolation points and function values to using at subsequent iterations. Despite the comparatively ad...

متن کامل

I/O-Efficient Well-Separated Pair Decomposition and its Applications

We present an external memory algorithm to compute a well-separated pair decomposition (WSPD) of a given point set P in d in O sort N I/Os using O N B blocks of external memory, where N is the number of points in P, and sort N denotes the I/O complexity of sorting N items. (Throughout this paper we assume that the dimension d is fixed). We also show how to dynamically maintain the WSPD in O log...

متن کامل

Insert Sort on SCM FSA 1

This article describes the insert sorting algorithm using macro instructions such as if-Macro (conditional branch macro instructions), for-loop macro instructions and While-Macro instructions etc. From the viewpoint of initialization, we generalize the halting and computing problem of the While-Macro. Generally speaking, it is difficult to judge whether the While-Macro is halting or not by way ...

متن کامل

Insert Sort on Scmpds

The goal of this article is to examine the effectiveness of “forloop” and “while-loop” statements on SCMPDS by insert sort. In this article, first of all, we present an approach to compute the execution result of “for-loop” program by “loop-invariant”, based on Hoare’s axioms for program verification. Secondly, we extend the fundamental properties of the finite sequence and complex instructions...

متن کامل

Insert Sort on SCMPDS 1

The goal of this article is to examine the effectiveness of “for-loop” and “while-loop” statements on SCMPDS by insert sort. In this article, first of all, we present an approach to compute the execution result of “for-loop” program by “loop-invariant”, based on Hoare’s axioms for program verification. Secondly, we extend the fundamental properties of the finite sequence and complex instruction...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2002